<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>git 笔记.md | 小波的博客</title><meta name="keywords" content="Git"><meta name="author" content="Steve"><meta name="copyright" content="Steve"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="git 笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="git 笔记.md">
<meta property="og:url" content="https://steve6636.gitee.io/2022/03/06/Git-study/index.html">
<meta property="og:site_name" content="小波的博客">
<meta property="og:description" content="git 笔记">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg">
<meta property="article:published_time" content="2022-03-06T14:47:18.000Z">
<meta property="article:modified_time" content="2022-03-06T14:52:51.588Z">
<meta property="article:author" content="Steve">
<meta property="article:tag" content="Git">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://steve6636.gitee.io/2022/03/06/Git-study/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-03-06 22:52:51'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="小波的博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210327175316.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="/friends"><i class="fa-fw fas fa-address-book"></i><span> Friends</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">小波的博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="/friends"><i class="fa-fw fas fa-address-book"></i><span> Friends</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">git 笔记.md</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-06T14:52:51.588Z" title="更新于 2022-03-06 22:52:51">2022-03-06</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Git/">Git</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>12分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="一、版本控制概述"><a href="#一、版本控制概述" class="headerlink" title="一、版本控制概述"></a>一、版本控制概述</h1><h2 id="1、为什么需要版本控制"><a href="#1、为什么需要版本控制" class="headerlink" title="1、为什么需要版本控制"></a>1、为什么需要版本控制</h2><p>一个人无法完成一个庞大项目的开发，而多人协作开发时需要使用相应的辅助工具。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215410.png" alt="images"></p>
<h2 id="2、版本控制工具"><a href="#2、版本控制工具" class="headerlink" title="2、版本控制工具"></a>2、版本控制工具</h2><ul>
<li><p>集中式版本控制工具</p>
<p>CVS、<span style="color:blue;font-weight:bold;">SVN(Subversion)</span>、VSS……</p>
</li>
<li><p>分布式版本控制工具</p>
<p><span style="color:blue;font-weight:bold;">Git</span>、Mercurial、Bazaar、Darcs……</p>
</li>
</ul>
<h1 id="二、Git概述"><a href="#二、Git概述" class="headerlink" title="二、Git概述"></a>二、Git概述</h1><h2 id="1、Git官网与Logo"><a href="#1、Git官网与Logo" class="headerlink" title="1、Git官网与Logo"></a>1、Git官网与Logo</h2><p>Git官网的网址是：<a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215416.png" alt="images"></p>
<p>Git的Logo中特意凸显了<span style="color:blue;font-weight:bold;">分支</span>功能，说明这是Git官方认为的Git最大特色。而我们在实际使用中也确实能够体会到Git的分支功能确实如丝般顺滑，非常好用。</p>
<p><img src= "/img/loading.gif" data-lazy-src="./images/img003.png" alt="images"></p>
<h2 id="2、Git简史"><a href="#2、Git简史" class="headerlink" title="2、Git简史"></a>2、Git简史</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215422.png" alt="images"></p>
<h2 id="3、Git工作机制"><a href="#3、Git工作机制" class="headerlink" title="3、Git工作机制"></a>3、Git工作机制</h2><h3 id="①本地库工作机制"><a href="#①本地库工作机制" class="headerlink" title="①本地库工作机制"></a>①本地库工作机制</h3><p>Git使用本地库在我们本地的电脑上就可以记录版本信息，不需要联网。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215431.png" alt="images"></p>
<h3 id="②代码托管中心"><a href="#②代码托管中心" class="headerlink" title="②代码托管中心"></a>②代码托管中心</h3><p>代码托管中心负责维护<span style="color:blue;font-weight:bold;">远程库</span>，让团队成员可以彼此协作。</p>
<ul>
<li><p>局域网</p>
<p>Gitlab：如果有特殊需求不能使用外网的代码托管中心，可以在局域网内搭建自己的代码托管中心服务器。</p>
</li>
<li><p>Internet</p>
<p>GitHub：国外网站，有非常多优秀的开源项目托管代码，但是从国内访问很慢。</p>
<p>码云：国内的代码托管中心，在国内互联网开发圈子中的地位举足轻重。</p>
</li>
</ul>
<h3 id="③远程库工作机制"><a href="#③远程库工作机制" class="headerlink" title="③远程库工作机制"></a>③远程库工作机制</h3><h4 id="1-团队内协作"><a href="#1-团队内协作" class="headerlink" title="[1]团队内协作"></a>[1]团队内协作</h4><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215436.png" alt="images"></p>
<h4 id="2-跨团队协作"><a href="#2-跨团队协作" class="headerlink" title="[2]跨团队协作"></a>[2]跨团队协作</h4><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215443.png" alt="images"></p>
<h1 id="三、Git安装"><a href="#三、Git安装" class="headerlink" title="三、Git安装"></a>三、Git安装</h1><p><a href="pages/installation.html">具体安装过程点这里</a>。</p>
<h1 id="四、本地库命令行基本操作"><a href="#四、本地库命令行基本操作" class="headerlink" title="四、本地库命令行基本操作"></a>四、本地库命令行基本操作</h1><h2 id="1、初始化本地库"><a href="#1、初始化本地库" class="headerlink" title="1、初始化本地库"></a>1、初始化本地库</h2><p>创建一个专门的目录，使用git init命令初始化为本地库，后面我们的版本控制操作都是在这个目录下进行。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215450.png" alt="images"></p>
<h2 id="2、设置用户签名"><a href="#2、设置用户签名" class="headerlink" title="2、设置用户签名"></a>2、设置用户签名</h2><p>签名的作用是区分不同操作者身份。用户的签名信息在每一个版本的提交信息中能够看到，以此确认本次提交是谁做的。</p>
<blockquote>
<p>注意：这里设置用户签名和将来登录GitHub（或其他代码托管中心）的账号没有任何关系。</p>
</blockquote>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215453.png" alt="images"></p>
<h2 id="3、创建文件并进行版本控制"><a href="#3、创建文件并进行版本控制" class="headerlink" title="3、创建文件并进行版本控制"></a>3、创建文件并进行版本控制</h2><h3 id="①新建文件"><a href="#①新建文件" class="headerlink" title="①新建文件"></a>①新建文件</h3><p>在初始化好本地库的这个目录中随便创建一个文本文件即可。</p>
<h3 id="②查看本地库状态"><a href="#②查看本地库状态" class="headerlink" title="②查看本地库状态"></a>②查看本地库状态</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215458.png" alt="images"></p>
<h3 id="③追踪文件并添加到暂存区"><a href="#③追踪文件并添加到暂存区" class="headerlink" title="③追踪文件并添加到暂存区"></a>③追踪文件并添加到暂存区</h3><p>git add命令有两个作用：</p>
<ul>
<li>对“未追踪”的文件进行追踪，也就是加入版本控制体系，被Git管理。</li>
<li>将工作区的变动（新增和修改）添加到暂存区</li>
</ul>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215503.png" alt="images"></p>
<h3 id="④再次查看本地库状态"><a href="#④再次查看本地库状态" class="headerlink" title="④再次查看本地库状态"></a>④再次查看本地库状态</h3><p>检测到有新建的文件添加到了暂存区</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215508.png" alt="images"></p>
<h3 id="⑤将暂存区中的修改提交到本地库"><a href="#⑤将暂存区中的修改提交到本地库" class="headerlink" title="⑤将暂存区中的修改提交到本地库"></a>⑤将暂存区中的修改提交到本地库</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215511.png" alt="images"></p>
<h3 id="⑥提交完成后再查看本地库状态"><a href="#⑥提交完成后再查看本地库状态" class="headerlink" title="⑥提交完成后再查看本地库状态"></a>⑥提交完成后再查看本地库状态</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215515.png" alt="images"></p>
<h2 id="4、修改文件进行版本控制"><a href="#4、修改文件进行版本控制" class="headerlink" title="4、修改文件进行版本控制"></a>4、修改文件进行版本控制</h2><h3 id="①修改文件后查看本地库状态"><a href="#①修改文件后查看本地库状态" class="headerlink" title="①修改文件后查看本地库状态"></a>①修改文件后查看本地库状态</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215518.png" alt="images"></p>
<h3 id="②工作区文件修改后添加到暂存区"><a href="#②工作区文件修改后添加到暂存区" class="headerlink" title="②工作区文件修改后添加到暂存区"></a>②工作区文件修改后添加到暂存区</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215522.png" alt="images"></p>
<h3 id="③后续操作"><a href="#③后续操作" class="headerlink" title="③后续操作"></a>③后续操作</h3><p>提交后再次查看状态，如果操作正确应该还是看到“working tree clean”。</p>
<h2 id="5、不add直接commit"><a href="#5、不add直接commit" class="headerlink" title="5、不add直接commit"></a>5、不add直接commit</h2><p>两种情况：</p>
<ul>
<li>新建的文件尚未纳入版本控制体系：必须先add纳入版本控制体系后才可以commit</li>
<li>已纳入版本控制体系的文件被修改：可以不add直接commit，Git自动执行了add</li>
</ul>
<h2 id="6、版本穿梭"><a href="#6、版本穿梭" class="headerlink" title="6、版本穿梭"></a>6、版本穿梭</h2><h3 id="①查看版本记录"><a href="#①查看版本记录" class="headerlink" title="①查看版本记录"></a>①查看版本记录</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215526.png" alt="images"></p>
<h3 id="②切换到指定版本"><a href="#②切换到指定版本" class="headerlink" title="②切换到指定版本"></a>②切换到指定版本</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215530.png" alt="images"></p>
<h3 id="③底层其实是移动HEAD指针"><a href="#③底层其实是移动HEAD指针" class="headerlink" title="③底层其实是移动HEAD指针"></a>③底层其实是移动HEAD指针</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215534.png" alt="images"></p>
<h1 id="五、本地库命令行分支操作"><a href="#五、本地库命令行分支操作" class="headerlink" title="五、本地库命令行分支操作"></a>五、本地库命令行分支操作</h1><h2 id="1、什么是分支"><a href="#1、什么是分支" class="headerlink" title="1、什么是分支"></a>1、什么是分支</h2><p>在使用版本控制工具开发的过程中，同时推进多个任务</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215538.png" alt="images"></p>
<h2 id="2、分支的好处"><a href="#2、分支的好处" class="headerlink" title="2、分支的好处"></a>2、分支的好处</h2><ul>
<li>同时并行推进多个功能开发，提高开发效率</li>
<li>各个分支在开发过程中，如果某一个分支开发失败，不会对其他分支有任何影响。失败的分支删除重新开始即可。</li>
</ul>
<h2 id="3、分支的底层实现"><a href="#3、分支的底层实现" class="headerlink" title="3、分支的底层实现"></a>3、分支的底层实现</h2><p>Git的分支操作之所以能够非常平滑，就是因为创建分支时，Git底层并没有把本地库中的内容复制出来，而仅仅是创建新的指针。有新版本提交后移动指针。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215542.png" alt="images"></p>
<p>master、hotfix其实都是指向具体版本记录的指针。当前所在的分支，其实是由HEAD决定的。<br/><br>所以创建分支的本质就是多创建一个指针。<br/><br>HEAD如果指向master，那么我们现在就在master分支上。<br/><br>HEAD如果指向hotfix，那么我们现在就在hotfix分支上。<br/><br>所以切换分支的本质就是移动HEAD指针。</p>
<h2 id="4、分支操作"><a href="#4、分支操作" class="headerlink" title="4、分支操作"></a>4、分支操作</h2><h3 id="①创建分支和切换分支"><a href="#①创建分支和切换分支" class="headerlink" title="①创建分支和切换分支"></a>①创建分支和切换分支</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215550.png" alt="images"></p>
<h3 id="②在两个不同分支分别做不同修改"><a href="#②在两个不同分支分别做不同修改" class="headerlink" title="②在两个不同分支分别做不同修改"></a>②在两个不同分支分别做不同修改</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215556.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215602.png" alt="images"></p>
<h3 id="③分支合并"><a href="#③分支合并" class="headerlink" title="③分支合并"></a>③分支合并</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215609.png" alt="images"></p>
<p>合并分支时一定是涉及到两个分支。这两个分支一个是“当前所在分支”，一个是“目标分支”。<br/><br>命令写法：git merge 目标分支<br/><br>所以分支合并命令的本质就是把“目标分支”合并到“当前分支”。<br/></p>
<blockquote>
<p>例如：把hotfix合并到master<br>git merge hotfix<br>需要确保当前所在的分支是master</p>
</blockquote>
<blockquote>
<p>例如：把master合并到hotfix<br>git merge master<br>需要确保当前所在的分支是hotfix</p>
</blockquote>
<h2 id="5、冲突"><a href="#5、冲突" class="headerlink" title="5、冲突"></a>5、冲突</h2><p>分支合并时，如果<span style="color:blue;font-weight:bold;">同一个文件</span>的<span style="color:blue;font-weight:bold;">同一个位置</span>有不同内容就会产生冲突。</p>
<h3 id="①冲突的表现"><a href="#①冲突的表现" class="headerlink" title="①冲突的表现"></a>①冲突的表现</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215614.png" alt="images"></p>
<p>Git使用“&lt;&lt;&lt;&lt;&lt;&lt;&lt;、=========、&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;”符号帮我们标记出来，现在产生冲突的内容。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</span><br><span class="line">Hello Git!I am very happy! &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</span><br><span class="line">Hello Git!I am very happy!</span><br><span class="line">=======</span><br><span class="line">表示HEAD指针指向的位置（其实就是当前分支）在冲突中的内容</span><br></pre></td></tr></table></figure>



<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=======</span><br><span class="line">Hello Git!I am very happy!</span><br><span class="line">Hello Git!I am very happy! ************</span><br><span class="line">&gt;&gt;&gt;&gt;&gt;&gt;&gt; hotfix</span><br><span class="line">表示hotfix指针指向的位置在冲突中的内容</span><br></pre></td></tr></table></figure>

<p>所以所谓冲突其实就是让我们在这二者中选择一个，Git无法替我们决定使用哪一个。必须人为决定新代码内容。<br/></p>
<p>此时使用git status命令查看本地库状态</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215624.png" alt="images"></p>
<h3 id="②冲突的解决"><a href="#②冲突的解决" class="headerlink" title="②冲突的解决"></a>②冲突的解决</h3><h4 id="1-第一步"><a href="#1-第一步" class="headerlink" title="[1]第一步"></a>[1]第一步</h4><p>编辑有冲突的文件，删除特殊符号，决定要使用的内容</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215631.png" alt="images"></p>
<h4 id="2-第二步"><a href="#2-第二步" class="headerlink" title="[2]第二步"></a>[2]第二步</h4><p>添加到暂存区</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215638.png" alt="images"></p>
<p>使用git status命令查看本地库状态</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215643.png" alt="images"></p>
<h4 id="3-第三步"><a href="#3-第三步" class="headerlink" title="[3]第三步"></a>[3]第三步</h4><p>执行提交（注意：使用git commit命令时不能带文件名）</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215648.png" alt="images"></p>
<h1 id="六、远程库命令行操作"><a href="#六、远程库命令行操作" class="headerlink" title="六、远程库命令行操作"></a>六、远程库命令行操作</h1><h2 id="1、创建远程库"><a href="#1、创建远程库" class="headerlink" title="1、创建远程库"></a>1、创建远程库</h2><p>登录后点这里：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215654.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="./images/img042.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215658.png" alt="images"></p>
<h2 id="2、团队内协作"><a href="#2、团队内协作" class="headerlink" title="2、团队内协作"></a>2、团队内协作</h2><h3 id="①在本地创建远程库地址别名"><a href="#①在本地创建远程库地址别名" class="headerlink" title="①在本地创建远程库地址别名"></a>①在本地创建远程库地址别名</h3><p>远程库地址太长了，我们需要在本地创建一个简短的别名便于引用</p>
<h4 id="1-先复制远程库地址"><a href="#1-先复制远程库地址" class="headerlink" title="[1]先复制远程库地址"></a>[1]先复制远程库地址</h4><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215715.png" alt="images"></p>
<h4 id="2-在本地创建远程库地址别名"><a href="#2-在本地创建远程库地址别名" class="headerlink" title="[2]在本地创建远程库地址别名"></a>[2]在本地创建远程库地址别名</h4><p>查看当前所有远程地址别名：git remote -v <br/></p>
<p>创建新的远程地址别名：git remote add 别名 远程地址</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215718.png" alt="images"></p>
<h3 id="②推送"><a href="#②推送" class="headerlink" title="②推送"></a>②推送</h3><p>git push 别名 分支</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215722.png" alt="images"></p>
<p>推送过程中需要填写账号密码</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215725.png" alt="images"></p>
<p>推送后可以刷新远程库所在页面，查看我们上传的文件</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215730.png" alt="images"></p>
<h3 id="③克隆"><a href="#③克隆" class="headerlink" title="③克隆"></a>③克隆</h3><p>团队其他人想拿到整个库就可以使用克隆功能。命令格式是：git clone 远程库地址<br/></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215735.png" alt="images"></p>
<p>克隆命令有三个效果：</p>
<ul>
<li>创建并初始化本地库，相当于执行了git init命令</li>
<li>创建远程地址别名，相当于执行了git remote add命令</li>
<li>把远程库文件下载到本地</li>
</ul>
<h3 id="④使用未加入团队的账号执行推送操作"><a href="#④使用未加入团队的账号执行推送操作" class="headerlink" title="④使用未加入团队的账号执行推送操作"></a>④使用未加入团队的账号执行推送操作</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215740.png" alt="images"></p>
<h3 id="⑤邀请团队成员加入远程库"><a href="#⑤邀请团队成员加入远程库" class="headerlink" title="⑤邀请团队成员加入远程库"></a>⑤邀请团队成员加入远程库</h3><h4 id="1-仓库主人发起邀请"><a href="#1-仓库主人发起邀请" class="headerlink" title="[1]仓库主人发起邀请"></a>[1]仓库主人发起邀请</h4><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215743.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215750.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215804.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="./images/img054.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215809.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215812.png" alt="images"></p>
<h4 id="2-被邀请人接受邀请"><a href="#2-被邀请人接受邀请" class="headerlink" title="[2]被邀请人接受邀请"></a>[2]被邀请人接受邀请</h4><p>被邀请人登录自己的码云账号，查看私信通知</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215816.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215819.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215823.png" alt="images"></p>
<h3 id="⑥加入团队后再尝试推送"><a href="#⑥加入团队后再尝试推送" class="headerlink" title="⑥加入团队后再尝试推送"></a>⑥加入团队后再尝试推送</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215827.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215830.png" alt="images"></p>
<h3 id="⑦通过拉取操作查看别人的修改"><a href="#⑦通过拉取操作查看别人的修改" class="headerlink" title="⑦通过拉取操作查看别人的修改"></a>⑦通过拉取操作查看别人的修改</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215834.png" alt="images"></p>
<h2 id="3、跨团队协作"><a href="#3、跨团队协作" class="headerlink" title="3、跨团队协作"></a>3、跨团队协作</h2><h3 id="①团队外：fork远程库"><a href="#①团队外：fork远程库" class="headerlink" title="①团队外：fork远程库"></a>①团队外：fork远程库</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215837.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215841.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215845.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215849.png" alt="images"></p>
<h3 id="②团队外：在fork仓库中修改代码"><a href="#②团队外：在fork仓库中修改代码" class="headerlink" title="②团队外：在fork仓库中修改代码"></a>②团队外：在fork仓库中修改代码</h3><p>如果要修改的代码很多，可以先clone到本地，修改完成后再push。如果修改不多可以直接在线修改。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215854.png" alt="images"></p>
<h3 id="③团队外：修改完成后发起pull-request"><a href="#③团队外：修改完成后发起pull-request" class="headerlink" title="③团队外：修改完成后发起pull request"></a>③团队外：修改完成后发起pull request</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215900.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215904.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215908.png" alt="images"></p>
<p>创建后效果如下：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215915.png" alt="images"></p>
<h3 id="④团队内：审核代码"><a href="#④团队内：审核代码" class="headerlink" title="④团队内：审核代码"></a>④团队内：审核代码</h3><p>首先审核者通过站内通知获知pull request请求</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215920.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215924.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215929.png" alt="images"></p>
<h3 id="⑤团队内：合并代码"><a href="#⑤团队内：合并代码" class="headerlink" title="⑤团队内：合并代码"></a>⑤团队内：合并代码</h3><p>需要团队内确认审核代码没有问题，并且有专人测试通过，然后依次点击审核通过、测试通过按钮。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215934.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215939.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215944.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215949.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024215953.png" alt="images"></p>
<h1 id="七、SSH方式连接"><a href="#七、SSH方式连接" class="headerlink" title="七、SSH方式连接"></a>七、SSH方式连接</h1><p>使用SSH非对称加密技术连接远程库可以实现免密登录</p>
<h2 id="1、本地创建SSH密钥文件"><a href="#1、本地创建SSH密钥文件" class="headerlink" title="1、本地创建SSH密钥文件"></a>1、本地创建SSH密钥文件</h2><blockquote>
<p>#进入当前用户的家目录</p>
<p>$ cd ~</p>
<p>#运行命令生成.ssh密钥目录，注意：这里-C这个参数是大写的C</p>
<p>$ ssh-keygen -t rsa -C <a href="mailto:&#x61;&#116;&#x67;&#117;&#105;&#103;&#x75;&#50;&#48;&#x31;&#56;&#121;&#x62;&#x75;&#x71;&#x40;&#97;&#108;&#x69;&#x79;&#117;&#110;&#46;&#99;&#x6f;&#109;">&#x61;&#116;&#x67;&#117;&#105;&#103;&#x75;&#50;&#48;&#x31;&#56;&#121;&#x62;&#x75;&#x71;&#x40;&#97;&#108;&#x69;&#x79;&#117;&#110;&#46;&#99;&#x6f;&#109;</a></p>
<p>#进入.ssh目录查看文件列表</p>
<p>$ cd .ssh</p>
<p>$ ls -lF</p>
<p>#查看id_rsa.pub文件内容</p>
<p>$ cat id_rsa.pub</p>
<p>#复制id_rsa.pub文件内容</p>
</blockquote>
<h2 id="2、在码云填写公钥"><a href="#2、在码云填写公钥" class="headerlink" title="2、在码云填写公钥"></a>2、在码云填写公钥</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220000.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220004.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220011.png" alt="images"></p>
<h2 id="3、本地操作"><a href="#3、本地操作" class="headerlink" title="3、本地操作"></a>3、本地操作</h2><blockquote>
<p>回到Git bash创建远程地址别名</p>
<p>git remote add origin_ssh <a href="mailto:&#x67;&#105;&#116;&#64;&#x67;&#105;&#116;&#x68;&#117;&#98;&#46;&#x63;&#111;&#109;">&#x67;&#105;&#116;&#64;&#x67;&#105;&#116;&#x68;&#117;&#98;&#46;&#x63;&#111;&#109;</a>:atguigu2018ybuq/huashan.git</p>
<p>推送文件进行测试</p>
</blockquote>
<h1 id="八、在IDEA中操作本地库"><a href="#八、在IDEA中操作本地库" class="headerlink" title="八、在IDEA中操作本地库"></a>八、在IDEA中操作本地库</h1><h2 id="1、配置忽略文件"><a href="#1、配置忽略文件" class="headerlink" title="1、配置忽略文件"></a>1、配置忽略文件</h2><h3 id="①哪些文件需要忽略？"><a href="#①哪些文件需要忽略？" class="headerlink" title="①哪些文件需要忽略？"></a>①哪些文件需要忽略？</h3><p>Eclipse工程特定文件</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220016.png" alt="images"></p>
<p>IDEA工程特定文件</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220021.png" alt="images"></p>
<p>编译产生的二进制文件（对于Maven工程来说就是target目录）</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220025.png" alt="images"></p>
<h3 id="②为什么要忽略这些文件？"><a href="#②为什么要忽略这些文件？" class="headerlink" title="②为什么要忽略这些文件？"></a>②为什么要忽略这些文件？</h3><p>与项目的实际功能无关，不参与服务器上部署运行。把它们忽略掉能够屏蔽IDE工具之间的差异，避免这些无关的文件对我们版本控制造成不必要的干扰。</p>
<h3 id="③忽略文件配置"><a href="#③忽略文件配置" class="headerlink" title="③忽略文件配置"></a>③忽略文件配置</h3><h4 id="1-创建忽略规则文件"><a href="#1-创建忽略规则文件" class="headerlink" title="[1] 创建忽略规则文件"></a>[1] 创建忽略规则文件</h4><p>这个文件的存放位置原则上在哪里都可以，为了便于让~/.gitconfig文件引用，建议也放在用户家目录下</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Compiled class file</span></span><br><span class="line"><span class="attr">*.class</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Log file</span></span><br><span class="line"><span class="attr">*.log</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># BlueJ files</span></span><br><span class="line"><span class="attr">*.ctxt</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Mobile Tools for Java (J2ME)</span></span><br><span class="line"><span class="attr">.mtj.tmp/</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Package Files #</span></span><br><span class="line"><span class="attr">*.jar</span></span><br><span class="line"><span class="attr">*.war</span></span><br><span class="line"><span class="attr">*.nar</span></span><br><span class="line"><span class="attr">*.ear</span></span><br><span class="line"><span class="attr">*.zip</span></span><br><span class="line"><span class="attr">*.tar.gz</span></span><br><span class="line"><span class="attr">*.rar</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml</span></span><br><span class="line"><span class="attr">hs_err_pid*</span></span><br><span class="line"></span><br><span class="line"><span class="attr">.classpath</span></span><br><span class="line"><span class="attr">.project</span></span><br><span class="line"><span class="attr">.settings</span></span><br><span class="line"><span class="attr">target</span></span><br><span class="line"><span class="attr">.idea</span></span><br><span class="line"><span class="attr">*.iml</span></span><br></pre></td></tr></table></figure>

<p>在这个文件中把我们要忽略的东西加上。目录或文件直接写名字即可。</p>
<h4 id="2-在-gitconfig文件中引用忽略规则文件"><a href="#2-在-gitconfig文件中引用忽略规则文件" class="headerlink" title="[2] 在.gitconfig文件中引用忽略规则文件"></a>[2] 在.gitconfig文件中引用忽略规则文件</h4><figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">[user]</span></span><br><span class="line">	<span class="attr">name</span> = <span class="string">peter</span></span><br><span class="line">	<span class="attr">email</span> = <span class="string">peter@atguigu.com</span></span><br><span class="line"><span class="attr">[core]</span></span><br><span class="line">	<span class="attr">excludesfile</span> = <span class="string">C:/Users/Lenovo/xxx.ignore</span></span><br></pre></td></tr></table></figure>

<p>注意：这里要使用“正斜线（/）”，不要使用“反斜线（\）”</p>
<h2 id="2、在IDEA中定位Git程序"><a href="#2、在IDEA中定位Git程序" class="headerlink" title="2、在IDEA中定位Git程序"></a>2、在IDEA中定位Git程序</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220031.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220036.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220041.png" alt="images"></p>
<h2 id="3、初始化本地库"><a href="#3、初始化本地库" class="headerlink" title="3、初始化本地库"></a>3、初始化本地库</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220046.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220049.png" alt="images"></p>
<h2 id="4、添加到暂存区"><a href="#4、添加到暂存区" class="headerlink" title="4、添加到暂存区"></a>4、添加到暂存区</h2><p>在工程目录上点右键：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220053.png" alt="images"></p>
<h2 id="5、提交到本地库"><a href="#5、提交到本地库" class="headerlink" title="5、提交到本地库"></a>5、提交到本地库</h2><p>在要提交的目录或文件这里点右键：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220058.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220101.png" alt="images"></p>
<h2 id="6、创建分支"><a href="#6、创建分支" class="headerlink" title="6、创建分支"></a>6、创建分支</h2><p>在窗口右下角：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220104.png" alt="images"></p>
<p>输入分支名称：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220109.png" alt="images"></p>
<h2 id="7、切换分支"><a href="#7、切换分支" class="headerlink" title="7、切换分支"></a>7、切换分支</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220113.png" alt="images"></p>
<h2 id="8、合并分支"><a href="#8、合并分支" class="headerlink" title="8、合并分支"></a>8、合并分支</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220117.png" alt="images"></p>
<h2 id="9、解决冲突"><a href="#9、解决冲突" class="headerlink" title="9、解决冲突"></a>9、解决冲突</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220122.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220126.png" alt="images"></p>
<h1 id="九、在IDEA中操作远程库"><a href="#九、在IDEA中操作远程库" class="headerlink" title="九、在IDEA中操作远程库"></a>九、在IDEA中操作远程库</h1><h2 id="1、给IDEA安装码云插件"><a href="#1、给IDEA安装码云插件" class="headerlink" title="1、给IDEA安装码云插件"></a>1、给IDEA安装码云插件</h2><p>在IDEA中连接码云需要在IDEA中安装码云插件，官方参考文档地址是：<a target="_blank" rel="noopener" href="https://gitee.com/help/articles/4117#article-header0">https://gitee.com/help/articles/4117#article-header0</a></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220131.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220135.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="./images/img102.png" alt="images"></p>
<h2 id="2、把我们的码云账号告诉IDEA"><a href="#2、把我们的码云账号告诉IDEA" class="headerlink" title="2、把我们的码云账号告诉IDEA"></a>2、把我们的码云账号告诉IDEA</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220139.png" alt="images"></p>
<h2 id="3、分享工程"><a href="#3、分享工程" class="headerlink" title="3、分享工程"></a>3、分享工程</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220148.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220153.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220156.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220159.png" alt="images"></p>
<h2 id="4、克隆远程库"><a href="#4、克隆远程库" class="headerlink" title="4、克隆远程库"></a>4、克隆远程库</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220203.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220207.png" alt="images"></p>
<p>下面的提示点击yes</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220211.png" alt="images"></p>
<p>如果保存clone文件的目录和工程不同名则会出现下面的效果：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220215.png" alt="images"></p>
<h2 id="5、推送和拉取"><a href="#5、推送和拉取" class="headerlink" title="5、推送和拉取"></a>5、推送和拉取</h2><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220218.png" alt="images"></p>
<h2 id="6、拉取远程库的新的分支"><a href="#6、拉取远程库的新的分支" class="headerlink" title="6、拉取远程库的新的分支"></a>6、拉取远程库的新的分支</h2><h3 id="①更新工程让本地能看到远程的新的分支"><a href="#①更新工程让本地能看到远程的新的分支" class="headerlink" title="①更新工程让本地能看到远程的新的分支"></a>①更新工程让本地能看到远程的新的分支</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220224.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220232.png" alt="images"></p>
<h3 id="②查看远程分支中是否显示了新的分支"><a href="#②查看远程分支中是否显示了新的分支" class="headerlink" title="②查看远程分支中是否显示了新的分支"></a>②查看远程分支中是否显示了新的分支</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220236.png" alt="images"></p>
<p>只要能看到这个分支显示了，那么就能够切换到这个分支，这样本地也有这个分支了。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220240.png" alt="images"></p>
<p>剩下就是本地的分支操作。</p>
<h1 id="十、Gitlab安装"><a href="#十、Gitlab安装" class="headerlink" title="十、Gitlab安装"></a>十、Gitlab安装</h1><p>注意：要使用CentOS7版本安装，CentOS6版本不行。</p>
<h2 id="1、官网地址"><a href="#1、官网地址" class="headerlink" title="1、官网地址"></a>1、官网地址</h2><p>首页：<a target="_blank" rel="noopener" href="https://about.gitlab.com/">https://about.gitlab.com/</a><br/></p>
<p>安装说明：<a target="_blank" rel="noopener" href="https://about.gitlab.com/installation/">https://about.gitlab.com/installation/</a></p>
<h2 id="2、提前下载所需rpm"><a href="#2、提前下载所需rpm" class="headerlink" title="2、提前下载所需rpm"></a>2、提前下载所需rpm</h2><p>yum安装gitlab-ee(或ce)时，需要联网下载几百M的安装文件，非常耗时，所以应提前把所需RPM包下载并安装好。可以尝试用迅雷下载，比较快。下载地址是：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.8.2-ce.0.el7.x86_64.rpm</span><br></pre></td></tr></table></figure>

<p>下载好后上传到Linux系统，习惯上还是放在/opt目录下。</p>
<h2 id="3、安装步骤"><a href="#3、安装步骤" class="headerlink" title="3、安装步骤"></a>3、安装步骤</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">sudo rpm -ivh /opt/gitlab-ce-10.8.2-ce.0.el7.x86_64.rpm</span><br><span class="line"></span><br><span class="line">sudo yum install -y curl policycoreutils-python openssh-server cronie</span><br><span class="line"></span><br><span class="line">sudo lokkit -s http -s ssh</span><br><span class="line"></span><br><span class="line">sudo yum install -y postfix</span><br><span class="line"></span><br><span class="line">sudo service postfix start</span><br><span class="line"></span><br><span class="line">sudo chkconfig postfix on</span><br><span class="line"></span><br><span class="line">curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-**c**e/script.rpm.sh | sudo bash</span><br><span class="line"></span><br><span class="line">sudo EXTERNAL_URL=&quot;http://gitlab.example.com&quot; yum -y install gitlab-**c**e</span><br></pre></td></tr></table></figure>

<p>把上面的命令放在shell文件中批量执行。执行完成后reboot。</p>
<h2 id="4、启动并初始化Gitlab服务"><a href="#4、启动并初始化Gitlab服务" class="headerlink" title="4、启动并初始化Gitlab服务"></a>4、启动并初始化Gitlab服务</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">初始化配置</span></span><br><span class="line">gitlab-ctl reconfigure</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">启动Gitlab服务</span></span><br><span class="line">gitlab-ctl start</span><br></pre></td></tr></table></figure>

<p>PS：如需停止Gitlab服务可以运行gitlab-ctl stop</p>
<h2 id="5、浏览器访问Gitlab服务"><a href="#5、浏览器访问Gitlab服务" class="headerlink" title="5、浏览器访问Gitlab服务"></a>5、浏览器访问Gitlab服务</h2><p>访问Linux服务器IP地址即可，如果想访问EXTERNAL_URL指定的域名还需要配置域名服务器或本地hosts文件。<br/></p>
<p>初次登录时需要为gitlab的root用户设置密码。</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220250.png" alt="images"></p>
<h2 id="6、命令行访问Gitlab"><a href="#6、命令行访问Gitlab" class="headerlink" title="6、命令行访问Gitlab"></a>6、命令行访问Gitlab</h2><p>在Gitlab中创建Project（相当于远程库）之后，复制Project的访问地址，在Git中创建这个地址的别名</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220257.png" alt="images"></p>
<p>后面按照这个别名执行交互操作即可</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220301.png" alt="images"></p>
<h2 id="7、IDEA中使用"><a href="#7、IDEA中使用" class="headerlink" title="7、IDEA中使用"></a>7、IDEA中使用</h2><h3 id="①按照Gitlab插件"><a href="#①按照Gitlab插件" class="headerlink" title="①按照Gitlab插件"></a>①按照Gitlab插件</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220304.png" alt="images"></p>
<h3 id="②设置Gitlab插件"><a href="#②设置Gitlab插件" class="headerlink" title="②设置Gitlab插件"></a>②设置Gitlab插件</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220309.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220312.png" alt="images"></p>
<p>这里我们需要访问gitlab.exampel.com域名，所以需要在系统中配置hosts。配置文件的路径是：C:\Windows\System32\drivers\etc\hosts</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">192.168.198.100 gitlab.example.com</span><br></pre></td></tr></table></figure>

<h3 id="③分享工程到Gitlab"><a href="#③分享工程到Gitlab" class="headerlink" title="③分享工程到Gitlab"></a>③分享工程到Gitlab</h3><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220317.png" alt="images"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220320.png" alt="images"></p>
<h1 id="十一、总结"><a href="#十一、总结" class="headerlink" title="十一、总结"></a>十一、总结</h1><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20211024220324.png" alt="images"></p>
<ul>
<li>远程代码托管中心选择<ul>
<li>GitHub：外网、境外</li>
<li>码云：外网、国内★</li>
<li>Gitlab：内网</li>
</ul>
</li>
<li>远程库操作<ul>
<li>创建远程库（IDEA分享工程上去会自动创建远程库）</li>
<li>将远程库克隆到本地（在IDEA中克隆需要指定保存的目录，注意新的工程名称）</li>
<li>推送</li>
<li>拉取</li>
<li>fork和pull request在页面上操作即可</li>
</ul>
</li>
<li>本地库基本操作<ul>
<li>初始化：git init</li>
<li>设置签名<ul>
<li>git config –global user.name xxx</li>
<li>git config –global user.email <a href="mailto:&#120;&#120;&#x78;&#64;&#120;&#x78;&#x78;&#46;&#120;&#120;&#120;">&#120;&#120;&#x78;&#64;&#120;&#x78;&#x78;&#46;&#120;&#120;&#120;</a></li>
</ul>
</li>
<li>追踪文件：git add 文件名</li>
<li>将文件添加到暂存区：git add 文件名</li>
<li>将文件提交到本地库：git commit -m “日志信息” 文件名<ul>
<li>如果文件尚未追踪，则不能直接提交</li>
</ul>
</li>
<li>查看版本记录：git reflog</li>
<li>版本穿梭：git reset –hard 版本号的前7位</li>
</ul>
</li>
<li>本地库分支操作<ul>
<li>创建分支：git branch 分支名字</li>
<li>查看分支：git branch -v</li>
<li>切换分支：git checkout 分支名字</li>
<li>合并分支：git merge 目标分支名字<ul>
<li>效果是将目标分支合并到当前分支</li>
</ul>
</li>
<li>冲突相关<ul>
<li>产生：两个分支的当前版本中同一个文件在同一个位置不同</li>
<li>解决<ul>
<li>删除特殊符号</li>
<li>修改到满意的状态</li>
<li>使用git add [文件名]标记为已解决</li>
<li>使用git commit -m “日志”提交（注意：不能带文件名）</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Steve</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://steve6636.gitee.io/2022/03/06/Git-study/">https://steve6636.gitee.io/2022/03/06/Git-study/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://steve6636.gitee.io" target="_blank">小波的博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Git/">Git</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/wechat.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/alipay.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2022/03/06/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD%E5%91%BD%E4%BB%A4-20210722/"><img class="prev-cover" data-lazy-src="https://img2.baidu.com/it/u=1814268193,3619863984&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=632&amp;h=500" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">MySQL 数据库备份命令.md</div></div></a></div><div class="next-post pull-right"><a href="/2022/03/06/Junit&amp;jdk8%E6%96%B0%E7%89%B9%E6%80%A7/"><img class="next-cover" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.05sun.com%2Fup%2F2006%2F2020611101156542640.png&amp;refer=http%3A%2F%2Fimg.05sun.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1649170568&amp;t=1d3529a6cb00dac37673cce4473d9a89" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">jdk8 新特性.md</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210327175316.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">Steve</div><div class="author-info__description">路漫漫其修远兮，吾将上下而求索</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/forkiller"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/forkiller" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1518109600@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">冷灯看剑，剑上几番功名？炉香无须计苍生，纵一川烟逝，万丈云埋，孤阳还照古陵</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E6%A6%82%E8%BF%B0"><span class="toc-text">一、版本控制概述</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6"><span class="toc-text">1、为什么需要版本控制</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E5%B7%A5%E5%85%B7"><span class="toc-text">2、版本控制工具</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81Git%E6%A6%82%E8%BF%B0"><span class="toc-text">二、Git概述</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81Git%E5%AE%98%E7%BD%91%E4%B8%8ELogo"><span class="toc-text">1、Git官网与Logo</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81Git%E7%AE%80%E5%8F%B2"><span class="toc-text">2、Git简史</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81Git%E5%B7%A5%E4%BD%9C%E6%9C%BA%E5%88%B6"><span class="toc-text">3、Git工作机制</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E6%9C%AC%E5%9C%B0%E5%BA%93%E5%B7%A5%E4%BD%9C%E6%9C%BA%E5%88%B6"><span class="toc-text">①本地库工作机制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E4%BB%A3%E7%A0%81%E6%89%98%E7%AE%A1%E4%B8%AD%E5%BF%83"><span class="toc-text">②代码托管中心</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E8%BF%9C%E7%A8%8B%E5%BA%93%E5%B7%A5%E4%BD%9C%E6%9C%BA%E5%88%B6"><span class="toc-text">③远程库工作机制</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%9B%A2%E9%98%9F%E5%86%85%E5%8D%8F%E4%BD%9C"><span class="toc-text">[1]团队内协作</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E8%B7%A8%E5%9B%A2%E9%98%9F%E5%8D%8F%E4%BD%9C"><span class="toc-text">[2]跨团队协作</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%89%E3%80%81Git%E5%AE%89%E8%A3%85"><span class="toc-text">三、Git安装</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E6%9C%AC%E5%9C%B0%E5%BA%93%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C"><span class="toc-text">四、本地库命令行基本操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96%E6%9C%AC%E5%9C%B0%E5%BA%93"><span class="toc-text">1、初始化本地库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E8%AE%BE%E7%BD%AE%E7%94%A8%E6%88%B7%E7%AD%BE%E5%90%8D"><span class="toc-text">2、设置用户签名</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%B9%B6%E8%BF%9B%E8%A1%8C%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6"><span class="toc-text">3、创建文件并进行版本控制</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6"><span class="toc-text">①新建文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%BA%93%E7%8A%B6%E6%80%81"><span class="toc-text">②查看本地库状态</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E8%BF%BD%E8%B8%AA%E6%96%87%E4%BB%B6%E5%B9%B6%E6%B7%BB%E5%8A%A0%E5%88%B0%E6%9A%82%E5%AD%98%E5%8C%BA"><span class="toc-text">③追踪文件并添加到暂存区</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A3%E5%86%8D%E6%AC%A1%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%BA%93%E7%8A%B6%E6%80%81"><span class="toc-text">④再次查看本地库状态</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A4%E5%B0%86%E6%9A%82%E5%AD%98%E5%8C%BA%E4%B8%AD%E7%9A%84%E4%BF%AE%E6%94%B9%E6%8F%90%E4%BA%A4%E5%88%B0%E6%9C%AC%E5%9C%B0%E5%BA%93"><span class="toc-text">⑤将暂存区中的修改提交到本地库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A5%E6%8F%90%E4%BA%A4%E5%AE%8C%E6%88%90%E5%90%8E%E5%86%8D%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%BA%93%E7%8A%B6%E6%80%81"><span class="toc-text">⑥提交完成后再查看本地库状态</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E8%BF%9B%E8%A1%8C%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6"><span class="toc-text">4、修改文件进行版本控制</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%90%8E%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%BA%93%E7%8A%B6%E6%80%81"><span class="toc-text">①修改文件后查看本地库状态</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E5%B7%A5%E4%BD%9C%E5%8C%BA%E6%96%87%E4%BB%B6%E4%BF%AE%E6%94%B9%E5%90%8E%E6%B7%BB%E5%8A%A0%E5%88%B0%E6%9A%82%E5%AD%98%E5%8C%BA"><span class="toc-text">②工作区文件修改后添加到暂存区</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%90%8E%E7%BB%AD%E6%93%8D%E4%BD%9C"><span class="toc-text">③后续操作</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E4%B8%8Dadd%E7%9B%B4%E6%8E%A5commit"><span class="toc-text">5、不add直接commit</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E7%89%88%E6%9C%AC%E7%A9%BF%E6%A2%AD"><span class="toc-text">6、版本穿梭</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E6%9F%A5%E7%9C%8B%E7%89%88%E6%9C%AC%E8%AE%B0%E5%BD%95"><span class="toc-text">①查看版本记录</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E5%88%87%E6%8D%A2%E5%88%B0%E6%8C%87%E5%AE%9A%E7%89%88%E6%9C%AC"><span class="toc-text">②切换到指定版本</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%BA%95%E5%B1%82%E5%85%B6%E5%AE%9E%E6%98%AF%E7%A7%BB%E5%8A%A8HEAD%E6%8C%87%E9%92%88"><span class="toc-text">③底层其实是移动HEAD指针</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%94%E3%80%81%E6%9C%AC%E5%9C%B0%E5%BA%93%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%88%86%E6%94%AF%E6%93%8D%E4%BD%9C"><span class="toc-text">五、本地库命令行分支操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AF%E5%88%86%E6%94%AF"><span class="toc-text">1、什么是分支</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%88%86%E6%94%AF%E7%9A%84%E5%A5%BD%E5%A4%84"><span class="toc-text">2、分支的好处</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%86%E6%94%AF%E7%9A%84%E5%BA%95%E5%B1%82%E5%AE%9E%E7%8E%B0"><span class="toc-text">3、分支的底层实现</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E5%88%86%E6%94%AF%E6%93%8D%E4%BD%9C"><span class="toc-text">4、分支操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E5%88%9B%E5%BB%BA%E5%88%86%E6%94%AF%E5%92%8C%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF"><span class="toc-text">①创建分支和切换分支</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E5%9C%A8%E4%B8%A4%E4%B8%AA%E4%B8%8D%E5%90%8C%E5%88%86%E6%94%AF%E5%88%86%E5%88%AB%E5%81%9A%E4%B8%8D%E5%90%8C%E4%BF%AE%E6%94%B9"><span class="toc-text">②在两个不同分支分别做不同修改</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%88%86%E6%94%AF%E5%90%88%E5%B9%B6"><span class="toc-text">③分支合并</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E5%86%B2%E7%AA%81"><span class="toc-text">5、冲突</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E5%86%B2%E7%AA%81%E7%9A%84%E8%A1%A8%E7%8E%B0"><span class="toc-text">①冲突的表现</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E5%86%B2%E7%AA%81%E7%9A%84%E8%A7%A3%E5%86%B3"><span class="toc-text">②冲突的解决</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E7%AC%AC%E4%B8%80%E6%AD%A5"><span class="toc-text">[1]第一步</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E7%AC%AC%E4%BA%8C%E6%AD%A5"><span class="toc-text">[2]第二步</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E7%AC%AC%E4%B8%89%E6%AD%A5"><span class="toc-text">[3]第三步</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AD%E3%80%81%E8%BF%9C%E7%A8%8B%E5%BA%93%E5%91%BD%E4%BB%A4%E8%A1%8C%E6%93%8D%E4%BD%9C"><span class="toc-text">六、远程库命令行操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="toc-text">1、创建远程库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%9B%A2%E9%98%9F%E5%86%85%E5%8D%8F%E4%BD%9C"><span class="toc-text">2、团队内协作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E5%9C%A8%E6%9C%AC%E5%9C%B0%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E5%BA%93%E5%9C%B0%E5%9D%80%E5%88%AB%E5%90%8D"><span class="toc-text">①在本地创建远程库地址别名</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%85%88%E5%A4%8D%E5%88%B6%E8%BF%9C%E7%A8%8B%E5%BA%93%E5%9C%B0%E5%9D%80"><span class="toc-text">[1]先复制远程库地址</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%9C%A8%E6%9C%AC%E5%9C%B0%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E5%BA%93%E5%9C%B0%E5%9D%80%E5%88%AB%E5%90%8D"><span class="toc-text">[2]在本地创建远程库地址别名</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E6%8E%A8%E9%80%81"><span class="toc-text">②推送</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%85%8B%E9%9A%86"><span class="toc-text">③克隆</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A3%E4%BD%BF%E7%94%A8%E6%9C%AA%E5%8A%A0%E5%85%A5%E5%9B%A2%E9%98%9F%E7%9A%84%E8%B4%A6%E5%8F%B7%E6%89%A7%E8%A1%8C%E6%8E%A8%E9%80%81%E6%93%8D%E4%BD%9C"><span class="toc-text">④使用未加入团队的账号执行推送操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A4%E9%82%80%E8%AF%B7%E5%9B%A2%E9%98%9F%E6%88%90%E5%91%98%E5%8A%A0%E5%85%A5%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="toc-text">⑤邀请团队成员加入远程库</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E4%BB%93%E5%BA%93%E4%B8%BB%E4%BA%BA%E5%8F%91%E8%B5%B7%E9%82%80%E8%AF%B7"><span class="toc-text">[1]仓库主人发起邀请</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E8%A2%AB%E9%82%80%E8%AF%B7%E4%BA%BA%E6%8E%A5%E5%8F%97%E9%82%80%E8%AF%B7"><span class="toc-text">[2]被邀请人接受邀请</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A5%E5%8A%A0%E5%85%A5%E5%9B%A2%E9%98%9F%E5%90%8E%E5%86%8D%E5%B0%9D%E8%AF%95%E6%8E%A8%E9%80%81"><span class="toc-text">⑥加入团队后再尝试推送</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A6%E9%80%9A%E8%BF%87%E6%8B%89%E5%8F%96%E6%93%8D%E4%BD%9C%E6%9F%A5%E7%9C%8B%E5%88%AB%E4%BA%BA%E7%9A%84%E4%BF%AE%E6%94%B9"><span class="toc-text">⑦通过拉取操作查看别人的修改</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E8%B7%A8%E5%9B%A2%E9%98%9F%E5%8D%8F%E4%BD%9C"><span class="toc-text">3、跨团队协作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E5%9B%A2%E9%98%9F%E5%A4%96%EF%BC%9Afork%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="toc-text">①团队外：fork远程库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E5%9B%A2%E9%98%9F%E5%A4%96%EF%BC%9A%E5%9C%A8fork%E4%BB%93%E5%BA%93%E4%B8%AD%E4%BF%AE%E6%94%B9%E4%BB%A3%E7%A0%81"><span class="toc-text">②团队外：在fork仓库中修改代码</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%9B%A2%E9%98%9F%E5%A4%96%EF%BC%9A%E4%BF%AE%E6%94%B9%E5%AE%8C%E6%88%90%E5%90%8E%E5%8F%91%E8%B5%B7pull-request"><span class="toc-text">③团队外：修改完成后发起pull request</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A3%E5%9B%A2%E9%98%9F%E5%86%85%EF%BC%9A%E5%AE%A1%E6%A0%B8%E4%BB%A3%E7%A0%81"><span class="toc-text">④团队内：审核代码</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A4%E5%9B%A2%E9%98%9F%E5%86%85%EF%BC%9A%E5%90%88%E5%B9%B6%E4%BB%A3%E7%A0%81"><span class="toc-text">⑤团队内：合并代码</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%83%E3%80%81SSH%E6%96%B9%E5%BC%8F%E8%BF%9E%E6%8E%A5"><span class="toc-text">七、SSH方式连接</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E6%9C%AC%E5%9C%B0%E5%88%9B%E5%BB%BASSH%E5%AF%86%E9%92%A5%E6%96%87%E4%BB%B6"><span class="toc-text">1、本地创建SSH密钥文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%9C%A8%E7%A0%81%E4%BA%91%E5%A1%AB%E5%86%99%E5%85%AC%E9%92%A5"><span class="toc-text">2、在码云填写公钥</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E6%9C%AC%E5%9C%B0%E6%93%8D%E4%BD%9C"><span class="toc-text">3、本地操作</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AB%E3%80%81%E5%9C%A8IDEA%E4%B8%AD%E6%93%8D%E4%BD%9C%E6%9C%AC%E5%9C%B0%E5%BA%93"><span class="toc-text">八、在IDEA中操作本地库</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E9%85%8D%E7%BD%AE%E5%BF%BD%E7%95%A5%E6%96%87%E4%BB%B6"><span class="toc-text">1、配置忽略文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E5%93%AA%E4%BA%9B%E6%96%87%E4%BB%B6%E9%9C%80%E8%A6%81%E5%BF%BD%E7%95%A5%EF%BC%9F"><span class="toc-text">①哪些文件需要忽略？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%BF%BD%E7%95%A5%E8%BF%99%E4%BA%9B%E6%96%87%E4%BB%B6%EF%BC%9F"><span class="toc-text">②为什么要忽略这些文件？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%BF%BD%E7%95%A5%E6%96%87%E4%BB%B6%E9%85%8D%E7%BD%AE"><span class="toc-text">③忽略文件配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%88%9B%E5%BB%BA%E5%BF%BD%E7%95%A5%E8%A7%84%E5%88%99%E6%96%87%E4%BB%B6"><span class="toc-text">[1] 创建忽略规则文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%9C%A8-gitconfig%E6%96%87%E4%BB%B6%E4%B8%AD%E5%BC%95%E7%94%A8%E5%BF%BD%E7%95%A5%E8%A7%84%E5%88%99%E6%96%87%E4%BB%B6"><span class="toc-text">[2] 在.gitconfig文件中引用忽略规则文件</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%9C%A8IDEA%E4%B8%AD%E5%AE%9A%E4%BD%8DGit%E7%A8%8B%E5%BA%8F"><span class="toc-text">2、在IDEA中定位Git程序</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96%E6%9C%AC%E5%9C%B0%E5%BA%93"><span class="toc-text">3、初始化本地库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E6%B7%BB%E5%8A%A0%E5%88%B0%E6%9A%82%E5%AD%98%E5%8C%BA"><span class="toc-text">4、添加到暂存区</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E6%8F%90%E4%BA%A4%E5%88%B0%E6%9C%AC%E5%9C%B0%E5%BA%93"><span class="toc-text">5、提交到本地库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E5%88%9B%E5%BB%BA%E5%88%86%E6%94%AF"><span class="toc-text">6、创建分支</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7%E3%80%81%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF"><span class="toc-text">7、切换分支</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8%E3%80%81%E5%90%88%E5%B9%B6%E5%88%86%E6%94%AF"><span class="toc-text">8、合并分支</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9%E3%80%81%E8%A7%A3%E5%86%B3%E5%86%B2%E7%AA%81"><span class="toc-text">9、解决冲突</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B9%9D%E3%80%81%E5%9C%A8IDEA%E4%B8%AD%E6%93%8D%E4%BD%9C%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="toc-text">九、在IDEA中操作远程库</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E7%BB%99IDEA%E5%AE%89%E8%A3%85%E7%A0%81%E4%BA%91%E6%8F%92%E4%BB%B6"><span class="toc-text">1、给IDEA安装码云插件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E6%8A%8A%E6%88%91%E4%BB%AC%E7%9A%84%E7%A0%81%E4%BA%91%E8%B4%A6%E5%8F%B7%E5%91%8A%E8%AF%89IDEA"><span class="toc-text">2、把我们的码云账号告诉IDEA</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%86%E4%BA%AB%E5%B7%A5%E7%A8%8B"><span class="toc-text">3、分享工程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E5%85%8B%E9%9A%86%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="toc-text">4、克隆远程库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E6%8E%A8%E9%80%81%E5%92%8C%E6%8B%89%E5%8F%96"><span class="toc-text">5、推送和拉取</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E6%8B%89%E5%8F%96%E8%BF%9C%E7%A8%8B%E5%BA%93%E7%9A%84%E6%96%B0%E7%9A%84%E5%88%86%E6%94%AF"><span class="toc-text">6、拉取远程库的新的分支</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E6%9B%B4%E6%96%B0%E5%B7%A5%E7%A8%8B%E8%AE%A9%E6%9C%AC%E5%9C%B0%E8%83%BD%E7%9C%8B%E5%88%B0%E8%BF%9C%E7%A8%8B%E7%9A%84%E6%96%B0%E7%9A%84%E5%88%86%E6%94%AF"><span class="toc-text">①更新工程让本地能看到远程的新的分支</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E6%9F%A5%E7%9C%8B%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF%E4%B8%AD%E6%98%AF%E5%90%A6%E6%98%BE%E7%A4%BA%E4%BA%86%E6%96%B0%E7%9A%84%E5%88%86%E6%94%AF"><span class="toc-text">②查看远程分支中是否显示了新的分支</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8D%81%E3%80%81Gitlab%E5%AE%89%E8%A3%85"><span class="toc-text">十、Gitlab安装</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%AE%98%E7%BD%91%E5%9C%B0%E5%9D%80"><span class="toc-text">1、官网地址</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E6%8F%90%E5%89%8D%E4%B8%8B%E8%BD%BD%E6%89%80%E9%9C%80rpm"><span class="toc-text">2、提前下载所需rpm</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4"><span class="toc-text">3、安装步骤</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E5%90%AF%E5%8A%A8%E5%B9%B6%E5%88%9D%E5%A7%8B%E5%8C%96Gitlab%E6%9C%8D%E5%8A%A1"><span class="toc-text">4、启动并初始化Gitlab服务</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E6%B5%8F%E8%A7%88%E5%99%A8%E8%AE%BF%E9%97%AEGitlab%E6%9C%8D%E5%8A%A1"><span class="toc-text">5、浏览器访问Gitlab服务</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%AE%BF%E9%97%AEGitlab"><span class="toc-text">6、命令行访问Gitlab</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7%E3%80%81IDEA%E4%B8%AD%E4%BD%BF%E7%94%A8"><span class="toc-text">7、IDEA中使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0%E6%8C%89%E7%85%A7Gitlab%E6%8F%92%E4%BB%B6"><span class="toc-text">①按照Gitlab插件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1%E8%AE%BE%E7%BD%AEGitlab%E6%8F%92%E4%BB%B6"><span class="toc-text">②设置Gitlab插件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2%E5%88%86%E4%BA%AB%E5%B7%A5%E7%A8%8B%E5%88%B0Gitlab"><span class="toc-text">③分享工程到Gitlab</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8D%81%E4%B8%80%E3%80%81%E6%80%BB%E7%BB%93"><span class="toc-text">十一、总结</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Mysql%E7%9A%84%E4%BC%98%E5%8C%96-%E8%87%AA%E6%88%91%E6%8F%8F%E8%BF%B0/" title="MySQL 的优化.md"><img data-lazy-src="https://img2.baidu.com/it/u=1814268193,3619863984&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=632&amp;h=500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL 的优化.md"/></a><div class="content"><a class="title" href="/2022/03/06/Mysql%E7%9A%84%E4%BC%98%E5%8C%96-%E8%87%AA%E6%88%91%E6%8F%8F%E8%BF%B0/" title="MySQL 的优化.md">MySQL 的优化.md</a><time datetime="2022-03-06T14:54:18.000Z" title="发表于 2022-03-06 22:54:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD%E5%91%BD%E4%BB%A4-20210722/" title="MySQL 数据库备份命令.md"><img data-lazy-src="https://img2.baidu.com/it/u=1814268193,3619863984&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=632&amp;h=500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL 数据库备份命令.md"/></a><div class="content"><a class="title" href="/2022/03/06/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD%E5%91%BD%E4%BB%A4-20210722/" title="MySQL 数据库备份命令.md">MySQL 数据库备份命令.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Git-study/" title="git 笔记.md"><img data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="git 笔记.md"/></a><div class="content"><a class="title" href="/2022/03/06/Git-study/" title="git 笔记.md">git 笔记.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Junit&amp;jdk8%E6%96%B0%E7%89%B9%E6%80%A7/" title="jdk8 新特性.md"><img data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.05sun.com%2Fup%2F2006%2F2020611101156542640.png&amp;refer=http%3A%2F%2Fimg.05sun.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1649170568&amp;t=1d3529a6cb00dac37673cce4473d9a89" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jdk8 新特性.md"/></a><div class="content"><a class="title" href="/2022/03/06/Junit&amp;jdk8%E6%96%B0%E7%89%B9%E6%80%A7/" title="jdk8 新特性.md">jdk8 新特性.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Docker%20%E7%AC%94%E8%AE%B0_20210404/" title="Docker 笔记.md"><img data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20220306223850.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Docker 笔记.md"/></a><div class="content"><a class="title" href="/2022/03/06/Docker%20%E7%AC%94%E8%AE%B0_20210404/" title="Docker 笔记.md">Docker 笔记.md</a><time datetime="2022-03-06T14:29:58.000Z" title="发表于 2022-03-06 22:29:58">2022-03-06</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By Steve</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="true"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>